import { Injectable } from '@angular/core';
import { Task, TaskService } from './task.service';
import { Resolve, ActivatedRouteSnapshot } from '@angular/router';

@Injectable({
  providedIn: 'root'
})
export class DetailsService implements Resolve<Task> {
  constructor(private taskService: TaskService) { }
  async resolve(route: ActivatedRouteSnapshot) {
    const id = Number(route.queryParamMap.get('id'));
    const task = await this.taskService.get(id);
    return task;
  }
}